package com.gy.api.pc.movie.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.github.pagehelper.PageInfo;
import com.gy.api.base.*;
import com.gy.api.pc.examine.domain.vo.ExamineCompleteUserVO;
import com.gy.api.pc.examine.domain.vo.ExamineCompleteVO;
import com.gy.api.pc.filings.domain.vo.WcContentExamineListVO;
import com.gy.api.pc.filings.domain.vo.WcPatentApplicationRecommendationAddVO;
import com.gy.api.pc.filings.domain.vo.WcPatentApplicationRecommendationVO;
import com.gy.api.pc.filings.service.IPatentApplicationService;
import com.gy.api.pc.movie.domain.vo.WcContentExamineDetailVO;
import com.gy.api.pc.movie.domain.vo.WcContentExaminePageListVO;
import com.gy.api.pc.movie.domain.vo.WcContentExamineSelectListDto;
import com.gy.api.pc.movie.service.IWcContentExamineService;
import com.gy.api.pc.sys.user.domain.vo.SysUserSearchVO;
import com.gy.api.pc.sys.user.domain.vo.SysUserVO;
import com.gy.api.pc.sys.user.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/wcContentExamine")
@Api( tags = ApiIndex.WcContentExamineController)
public class WcContentExamineController {

    @Autowired
    private IWcContentExamineService wcContentExamineService;

    @ApiOperation("影片内容审查--【受理】列表")
    @GetMapping("/acceptanceList")
    @ResponseBody
    public R<RestPage<WcContentExaminePageListVO>> acceptanceList( @ApiParam(value = "查询参数") @ModelAttribute WcContentExamineSelectListDto searchVO)  {
        searchVO.setApprovalUserId(StpUtil.getLoginIdAsString());
        searchVO.setNodeName(Constants.EXAMINE_MOVIE_LETTER[1]);
        List<WcContentExaminePageListVO> list = wcContentExamineService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }

    @ApiOperation("影片内容审查--【专家评审】列表")
    @GetMapping("/expertReviewList")
    @ResponseBody
    public R<RestPage<WcContentExaminePageListVO>> expertReviewList( @ApiParam(value = "查询参数") @ModelAttribute WcContentExamineSelectListDto searchVO)  {
        searchVO.setApprovalUserId(StpUtil.getLoginIdAsString());
        searchVO.setNodeName(Constants.EXAMINE_MOVIE_LETTER[2]);
        List<WcContentExaminePageListVO> list = wcContentExamineService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }

    @ApiOperation("影片内容审查--【审查决定】列表")
    @GetMapping("/reviewDecisionList")
    @ResponseBody
    public R<RestPage<WcContentExaminePageListVO>> reviewDecisionList( @ApiParam(value = "查询参数") @ModelAttribute WcContentExamineSelectListDto searchVO)  {
        searchVO.setApprovalUserId(StpUtil.getLoginIdAsString());
        searchVO.setNodeName(Constants.EXAMINE_MOVIE_LETTER[3]);
        List<WcContentExaminePageListVO> list = wcContentExamineService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }


    @ApiOperation("影片内容审查--【公示发证】列表")
    @GetMapping("/publicizeCertificationList")
    @ResponseBody
    public R<RestPage<WcContentExaminePageListVO>> publicizeCertificationList( @ApiParam(value = "查询参数") @ModelAttribute WcContentExamineSelectListDto searchVO)  {
        searchVO.setApprovalUserId(StpUtil.getLoginIdAsString());
        searchVO.setNodeName(Constants.EXAMINE_MOVIE_LETTER[4]);
        List<WcContentExaminePageListVO> list = wcContentExamineService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }
//
//    /**
//     * 导出影片内容审查列表
//     */
//    @ApiOperation("导出影片内容审查列表")
//    @PreAuthorize("@ss.hasPermi('system:contentExamine:export')")
//    @Log(title = "影片内容审查", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    @ResponseBody
//    public AjaxResult export(@RequestBody WcContentExamineSelectListDto dto) {
//        Page<WcContentExamineSelectListVO> list = wcContentExamineService.getList(dto);
//        ExcelUtil<WcContentExamineSelectListVO> util = new ExcelUtil<>(WcContentExamineSelectListVO.class);
//        return util.exportExcel(list.getRecords(), "影片内容审查数据");
//    }
//
//

    @ApiOperation("影片内容审查详情")
    @GetMapping("/edit/{id}")
    @ResponseBody
    public R<WcContentExamineDetailVO> edit(@PathVariable("id") String id) {
        WcContentExamineDetailVO vo = wcContentExamineService.selectWcContentExamineDetailVOById(id);
        return new R(vo);
    }


    @ApiOperation("完成审批/受理-不指派专家")
    @PostMapping("/complete")
    @SaCheckLogin
    public R complete(@RequestBody ExamineCompleteVO taskCompleteDto){
        wcContentExamineService.completeTask(taskCompleteDto);
        return new R();
    }


    @ApiOperation("受理-指派专家")
    @PostMapping("/complete_user")
    @SaCheckLogin
    public R complete_user(@RequestBody ExamineCompleteUserVO taskCompleteDto){
        wcContentExamineService.completeTaskUser(taskCompleteDto);
        return new R();
    }


    @Autowired
    private ISysUserService sysUserService;

    @ApiOperation(value = "查询专家用户列表（状态和角色ID 有可以不用管）")
    @GetMapping(value = "/user_list")
    @SaCheckLogin
    public R<RestPage<List<SysUserVO>>> user_list(
            @ApiParam(value = "查询参数") @ModelAttribute SysUserSearchVO searchVO) {
        searchVO.setUseState(1);
        if(StringUtils.isBlank(searchVO.getRoleId())){
            searchVO.setRoleId(Constants.EXAMINE_JIA_ROLE);
        }
        List<SysUserVO> list = sysUserService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }



    @Autowired
    IPatentApplicationService service;

    @ApiOperation("新增反馈国家电影局信息")
    @PostMapping("/add_recommendation")
    @ResponseBody
    public R addRecommendation(@RequestBody WcPatentApplicationRecommendationAddVO saveVO) throws Exception {
        service.addRecommendationExamine(saveVO);
        return new R();
    }


    @ApiOperation("查询反馈国家电影局信息")
    @GetMapping("/get_recommendation")
    public R<List<WcPatentApplicationRecommendationVO>> get_recommendation(@ApiParam(value = "查询参数") @ModelAttribute IDEntity saveVO) throws Exception {
        return new R(service.getRecommendationList(saveVO));
    }
}
